﻿@using Domain.NetworkService;
@model Domain.NetworkService.Description
@{
    var title = ViewBag.devName;
}
<div class="title">
    <h2>@title</h2>
</div>
@{
    if (ViewBag.devName != null && Domain.NetworkRemoteDevice.RemoteDeviceManager.hasDevice(ViewBag.devName))
    {
        List<string> list = new List<string>();

        foreach (NetworkTestDescription ntd in Enum.GetValues(typeof(NetworkTestDescription)))
        {
            list.Add(ntd.ToString());
        }
        IEnumerable<SelectListItem> col = list.Select(i => new SelectListItem()
        {
            Text = i.ToString(),
            Value = i
        });
    
    @Html.Label("Выбирете службу: ")
    @Html.DropDownList("NTD", col, new { id = "testChoose" });
    }
}
@if (ViewBag.devName != null && Domain.NetworkRemoteDevice.RemoteDeviceManager.hasDevice(ViewBag.devName))
{
    @Html.Partial(@"DevicePropertyForms\EchoDescriptionForm")
    @Html.Partial(@"DevicePropertyForms\NSDescriptionForm")
    @Html.Partial(@"DevicePropertyForms\SnmpDescriptionForm")
    @Html.Partial(@"DevicePropertyForms\TCPDescriptionForm")
}

@{
    if (ViewBag.devName != null && Domain.NetworkRemoteDevice.RemoteDeviceManager.hasDevice(ViewBag.devName))
    {
        int popupBoxCounter = 0;
        string devName = ViewBag.devName;
        var testList = @Domain.NetworkRemoteDevice.RemoteDeviceManager.GetTestsNamesOfRemoteDevice(devName);
        if (!String.IsNullOrEmpty(devName))
        {
  
    <table>
        @foreach (var t in testList)
        {
            popupBoxCounter++;
            <tr>
                <td>@Html.ActionLink(HttpUtility.HtmlDecode("&times;"),
                         "Manage",
                         "Manage",
                         new { testName = t.networkServiceTestID },
                      new { testName = t.networkServiceTestID, @class = "popup-link-" + popupBoxCounter, @id = "deleteSignCross" })
                </td>
                <td>@t.networkServiceTestID
                </td>
                <td>
                    @{string state = t.isActive ? "Вкл." : "Выкл.";}
                    @state
                </td>
                <td>@Html.ActionLink("Запуск",
                                  "StartTest",
                                  "Manage",
                            new { testName = t.networkServiceTestID, devName = ViewBag.devName },
                            new { testName = t.networkServiceTestID, devName = ViewBag.devName })
                </td>
                <td>@Html.ActionLink("Стоп",
                                     "StopTest",
                                     "Manage",
                               new { testName = t.networkServiceTestID, devName = ViewBag.devName },
                               new { testName = t.networkServiceTestID, devName = ViewBag.devName })
                </td>
                <td>
                @Html.ActionLink("Результаты", "SurveyDetailed", "Survey", new { devName = ViewBag.devName }, new { devName = ViewBag.devName })
                </td>
            </tr>
            
            <div class="popup-box" id="popup-box-@popupBoxCounter">
                <div class="close">
                    &times;</div>
                <div class="top">
                    <h2>
                        Подтверждение</h2>
                </div>
                <div class="bottom">
                    Вы точно хотите удалить службу "<b>@t.networkServiceTestID</b>"?<br />
                    <br />
                    <div class="yesNo">
                        @Html.ActionLink("Да",
                                         "RemoveTest",
                                         "Manage",
                                         new { testName = t.networkServiceTestID, devName = ViewBag.devName },
                                         new { testName = t.networkServiceTestID, devName = ViewBag.devName })
                        
                    </div>
                </div>
            </div>  
        }
    </table>
        }
    }
    else
    {
    @Html.Partial("ErrorDeviceNotFound");
    }
    
}
